home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS02.ADF / Make / vars.c < prev    next >
C/C++ Source or Header  |  1989-05-30  |  1KB  |  51 lines

  1.  
  2. /* vars.c */
  3.  
  4. #include "vars.h"
  5. #define NULL 0
  6. extern int debug;
  7.  
  8. DefineVar( pch_varname , pch_value )
  9.    char *pch_varname, *pch_value;
  10. {
  11.    int pos;
  12.  
  13.    pos = _Lookup( pch_varname );
  14.    if( debug )
  15.       printf( "Found var '%s' at position %d, defining as %s\n", pch_varname,pos, pch_value );
  16.    if( NULL != avr_Vars[ pos ].string)
  17.       printf("Redefining %s\n", pch_varname );
  18.    avr_Vars[pos].string = pch_value;
  19. }
  20.  
  21. char *
  22. VarLookup( pch_varname )
  23.    char *pch_varname;
  24. {
  25.    int pos;
  26.  
  27.    pos = _Lookup( pch_varname );
  28.    if( debug )
  29.       printf("found '%s' at position %d, value is %s\n", pch_varname, pos, avr_Vars[pos].string );
  30.    return avr_Vars[pos].string;
  31. }
  32.  
  33. static int
  34. _Lookup( pch_varname )
  35.    char *pch_varname;
  36. {
  37.    int pos;
  38.  
  39.    avr_Vars[n_Vars].pch_name = pch_varname;
  40.    avr_Vars[n_Vars].string = NULL;
  41.    pos = 0;
  42.    while( strcmp(pch_varname, avr_Vars[pos].pch_name ))
  43.       pos++;
  44.    if( pos == n_Vars )
  45.       n_Vars++;
  46.    return pos;
  47. }
  48.  
  49. int n_Vars = 0;
  50. struct var avr_Vars[ MAXVARS ];
  51.